package com.qf.mapper;

import com.qf.entity.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class TestMyBatis {

    @Test
    private void  myBatis() throws IOException {
        //加载工厂材料
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatis-Config.xml");

        //获得工厂构建和工厂
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(resourceAsStream);

        //由工厂获得Sqlsession对象
        SqlSession sqlSession = factory.openSession();

        // 生成代理对象 执行相应的方法
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);

        Integer integer = mapper.FindUserCount();

        List<User> userList = mapper.FindUserName();


    }
}
